<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/1/2
 * Time: 21:52
 */

//strrpos — 计算指定字符串在目标字符串中最后一次出现的位置
$haystack = "the year is 2017,so I want to do some import things of this year";
//           0123456789
$pos      = strrpos( $haystack, "year" ); //full match
echo $pos.PHP_EOL;

$pos      = strrpos( $haystack, "e",5); //full match
echo $pos.PHP_EOL;

$foo = "0123456789a123456789b123456789c";

var_dump(strrpos($foo, '7', -5));  // 从尾部第 5 个位置开始查找
// 结果: int(17)

var_dump(strrpos($foo, '7', 20));  // 从第 20 个位置开始查找
// 结果: int(27)

var_dump(strrpos($foo, '7', 28));  // 结果: bool(false)